#!/bin/bash


url="172.16.94.142:8080/api/v1/nodes"




pingcmd()

{
	ping -w 1 -c 1 $1>/dev/null
	ret=$?
	if [ $ret -eq 0 ];
	then 
		echo -e "$2 is up \n"

	else
		echo -e "$2 is down \n"
	fi

	return 0
}






check_k8sNode_NetBridge(){



j=0
for i in $(curl -G -s $url |grep podCIDR|awk -F ":" '{print $2}'|awk -F '\"' '{print $2}'|awk -F '0/24' '{print $1}')


do  
	 Nodename=$(curl -G -s 172.16.94.142:8080/api/v1/nodes |jq ".items[$j].metadata.name" )
         j=$(expr $j + 1)
	 pingcmd ${i}1 $Nodename




done



}




check_k8sNode_NetBridge
